package com.dqx.opengl_es_demo.model;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.dqx.opengl_es_demo.R;

/**
 * 绘制3D模型
 */
public class ModelActivity extends AppCompatActivity implements View.OnClickListener {
    Button btn_translate;
    Button btn_scal;
    Button btn_rotate;

    ModelGLSurfaceView surface_view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_model);

        surface_view = findViewById(R.id.surface_view);

        btn_translate = findViewById(R.id.btn_translate);
        btn_scal = findViewById(R.id.btn_scal);
        btn_rotate = findViewById(R.id.btn_rotate);

        btn_translate.setOnClickListener(this);
        btn_scal.setOnClickListener(this);
        btn_rotate.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_translate://平移
                surface_view.setCanTranslate(true);
                surface_view.setCanScal(false);
                surface_view.setCanRotate(false);
                break;
            case R.id.btn_scal://缩放
                surface_view.setCanTranslate(false);
                surface_view.setCanScal(true);
                surface_view.setCanRotate(false);
                break;
            case R.id.btn_rotate://旋转
                surface_view.setCanTranslate(false);
                surface_view.setCanScal(false);
                surface_view.setCanRotate(true);
                break;
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        surface_view.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        surface_view.onPause();
    }
}
